﻿Imports DataAccess
Public Class DistribuidorBL
    Public Shared Function List() As List(Of distribuidores)
        Dim lista As New List(Of DISTRIBUIDORES)
        lista = DISTRIBUIDORDAL.List
        Return lista
    End Function
    Public Shared Function save(ByVal zObject As distribuidores) As distribuidores
        If DistribuidorDAL.Exist(zObject.DISTRIBUIDOR) Then
            Return DistribuidorDAL.Update(zObject)
        Else
            Return DistribuidorDAL.Create(zObject)
        End If
    End Function
    Public Shared Function Delete(ByVal zId As Long) As Boolean
        Return DISTRIBUIDORDAL.Delete(zId)
    End Function
    Public Shared Function SearchByRut(ByVal zRut As String) As distribuidores
        Return DISTRIBUIDORDAL.SearchByRut(zRut)
    End Function
    Public Shared Function SearchById(ByVal zId As Long) As distribuidores
        Return DISTRIBUIDORDAL.SearchById(zId)
    End Function
    Public Shared Function GetNombre(ByVal zId As Long) As String
        Dim obj As New DISTRIBUIDORES
        obj = DISTRIBUIDORDAL.SearchById(zId)
        If Not IsNothing(obj) Then
            Return obj.NOMBRES
        Else
            Return ""
        End If
    End Function
End Class
